<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>角色管理- <s:text name="context.title"/></title>
	<link href="${ctx}/css/style.css" type="text/css" rel="stylesheet"/>
	<link href="${ctx}/js/validate/jquery.validate.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/js/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/js/validate/messages_cn.js" type="text/javascript"></script>
		<link href="${ctx}/css/style.css" rel="stylesheet" type="text/css"></link>
	<link type="text/css" href="${ctx}/css/redmond/jquery-ui-1.8.22.custom.css" rel="stylesheet" />

	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#name").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate();
		});
	function allSelect(obj){
		var jobj = $(obj);
		var _p = jobj.parent().next();
		var checkboxs = _p.find("input[type=checkbox]");
		checkboxs.each(function(inx,o){
			$(o).attr("checked","checked");
			});
	}

	function allCencel(obj){
		var jobj = $(obj);
		var _p = jobj.parent().next();
		var checkboxs = _p.find("input[type=checkbox]");
		checkboxs.each(function(inx,o){
			$(o).removeAttr("checked");
			});
	}

	function restore(obj){
		allCencel(obj);
		var jobj = $(obj);
		var _p = jobj.parent().next();
		var checkboxs = _p.find(".chx").attr("checked","checked");
		
	}
	</script>
</head>

<body>
	<h1 class="title01"><img src="${ctx}/images/02_15.gif" width="45" height="42" class="fl"/><a href="#">更多</a><s:if test="id == null">创建</s:if><s:else>修改</s:else>角色 </h1>
	<form action="role!save.action" method="post" id="inputForm">
		<input type="hidden" name="id" value="${id}"/>
		
		<fieldset class="fs_ys">
			<legend><s:if test="id == null">创建</s:if><s:else>修改</s:else>角色 </legend>
		    
		   <p>角色名:<input type="text" id="name" name="name" size="40" value="${name}" class="required"/></p>
			<p>授权:</p>
			<p>
				<s:iterator value="allAuthForMap.keys" var="v">
					<fieldset class="">
						<legend><s:property value="#v"/>  <span onclick="allSelect(this)" style="font-size: 1;color: blue;cursor: pointer;">全选</span>/<span onclick="allCencel(this)" style="font-size: 1;color: blue;cursor: pointer;">取消</span>/<span style="font-size: 1;color: blue;cursor: pointer;" onclick="restore(this)" title="只恢复本未提交的">恢复</span></legend>
						<p>
							<s:checkboxlist name="checkedAuthIds" list="allAuthForMap[#v]" listKey="id" cssClass="chx"  listValue="name" theme="custom"/>
						</p>
					</fieldset>			
				</s:iterator>
			</p>
			<p><security:authorize ifAnyGranted="ROLE_修改角色">
						<input class="button" type="submit" value="提交"/>&nbsp;
					</security:authorize>
					<input class="button" type="button" value="返回" onclick="history.back()"/>
			</p>		
		</fieldset>
	</form>
</body>
</html>
